module.exports = (sequelize, DataTypes) => {
  const HealthReport = sequelize.define('HealthReport', {
    id: {
      type: DataTypes.INTEGER,
      primaryKey: true,
      autoIncrement: true
    },
    member_id: {
      type: DataTypes.INTEGER,
      allowNull: false,
      comment: '关联家庭成员ID'
    },
    title: {
      type: DataTypes.STRING,
      allowNull: false,
      comment: '报告标题'
    },
    content: {
      type: DataTypes.TEXT,
      allowNull: true,
      comment: '报告内容'
    },
    report_type: {
      type: DataTypes.ENUM('physical', 'blood', 'imaging', 'other'),
      defaultValue: 'other',
      comment: '报告类型：体检、血液检查、影像检查、其他'
    },
    report_date: {
      type: DataTypes.DATEONLY,
      allowNull: false,
      comment: '报告日期'
    },
    hospital: {
      type: DataTypes.STRING,
      allowNull: true,
      comment: '医院名称'
    },
    doctor: {
      type: DataTypes.STRING,
      allowNull: true,
      comment: '医生姓名'
    },
    status: {
      type: DataTypes.ENUM('normal', 'warning', 'abnormal'),
      defaultValue: 'normal',
      comment: '报告状态：正常、警告、异常'
    },
    file_url: {
      type: DataTypes.STRING,
      allowNull: true,
      comment: '报告文件URL'
    },
    summary: {
      type: DataTypes.TEXT,
      allowNull: true,
      comment: '报告摘要'
    },
    recommendations: {
      type: DataTypes.TEXT,
      allowNull: true,
      comment: '建议'
    }
  }, {
    tableName: 'health_reports',
    timestamps: true,
    paranoid: true
  });

  HealthReport.associate = function(models) {
    HealthReport.belongsTo(models.FamilyMember, {
      foreignKey: 'member_id',
      as: 'member'
    });
  };

  return HealthReport;
}; 